package com.admin.system.modules.system.service.impl;

import com.admin.common.utils.PageResult;
import com.admin.common.utils.PageUtil;
import com.admin.core.dto.DictDetailQueryDTO;
import com.admin.core.entity.SysDictDetail;
import com.admin.core.mapper.DictDetailMapper;
import com.admin.system.modules.system.service.DictDetailService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author sq-lan
 */
@Service
@RequiredArgsConstructor
public class DictDetailServiceImpl extends ServiceImpl<DictDetailMapper, SysDictDetail> implements DictDetailService {

    @Override
    public PageResult<SysDictDetail> paging(DictDetailQueryDTO dto) {
        PageHelper.startPage(dto.getCurrent(), dto.getSize());
        LambdaQueryWrapper<SysDictDetail> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(dto.getDictId() != null, SysDictDetail::getDictId, dto.getDictId());
        List<SysDictDetail> list = this.list(wrapper);
        return PageUtil.toPageHelper(list);
    }

}
